package com.kexin.fpay.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * 聚合支付参数配置
 * @author ao
 */
@Configuration
public class FPayConfig {

	/** 接口请求跟路径 **/
	@Value("${fpay.baseUrl}")
	private String baseUrl;

	/** 外部渠道ID，聚合支付分配 **/
	@Value("${fpay.appId}")
	private String appId;

	/** 平台grantType **/
	@Value("${fpay.grantType}")
	private String grantType;

	/** 平台clientId **/
	@Value("${fpay.clientId}")
	private String clientId;

	/** 聚合支付验签 **/
	@Value("${fpay.clientSecret}")
	private String clientSecret;

	/** 异步通知key **/
	@Value("${coupon.appKey}")
	private String appKey;

	/** 异步通知验签 **/
	@Value("${coupon.appSecret}")
	private String appSecret;

	/** 渠道类型 **/
	@Value("${fpay.channelType}")
	private String channelType;

	/** 版本号 **/
	@Value("${fpay.version}")
	private String version;

	/** 商户号 **/
	@Value("${fpay.merNo}")
	private String merNo;

	/** 结果异步通知地址 **/
	@Value("${fpay.notifyUrl}")
	private String notifyUrl;

	/** 获取token接口url **/
	@Value("${fpay.getAuthorizationUrl}")
	private String getAuthorizationUrl;

	/** 统一下单接口url **/
	@Value("${fpay.placeAnOrderUrl}")
	private String placeAnOrderUrl;

	/** 订单退款接口url **/
	@Value("${fpay.refundUrl}")
	private String refundUrl;

	/** 订单查询接口url **/
	@Value("${fpay.queryUrl}")
	private String queryUrl;

	/** 获取对账单下载URL接口的url **/
	@Value("${fpay.billDownloadUrl}")
	private String billDownloadUrl;

	/** 支付金额（测试用，正数为固定金额，0和负数为传的实际金额，正式为0） **/
	@Value("${fpay.payAmount}")
	private String payAmount;

	private static FPayConfig fPayConfig;

	@PostConstruct
	public void init() {
		fPayConfig = this;
		fPayConfig.baseUrl = baseUrl;
		fPayConfig.appId = appId;
		fPayConfig.grantType = grantType;
		fPayConfig.clientId = clientId;
		fPayConfig.clientSecret = clientSecret;
		fPayConfig.appKey = appKey;
		fPayConfig.appSecret = appSecret;
		fPayConfig.channelType = channelType;
		fPayConfig.version = version;
		fPayConfig.merNo = merNo;
		fPayConfig.notifyUrl = notifyUrl;
		fPayConfig.getAuthorizationUrl = getAuthorizationUrl;
		fPayConfig.placeAnOrderUrl = placeAnOrderUrl;
		fPayConfig.refundUrl = refundUrl;
		fPayConfig.queryUrl = queryUrl;
		fPayConfig.billDownloadUrl = billDownloadUrl;
		fPayConfig.payAmount = payAmount;
	}

	public static String getBaseUrl() {
		return fPayConfig.baseUrl;
	}

	public static String getAppId() {
		return fPayConfig.appId;
	}

	public static String getGrantType() {
		return fPayConfig.grantType;
	}

	public static String getClientId() {
		return fPayConfig.clientId;
	}

	public static String getClientSecret() {
		return fPayConfig.clientSecret;
	}

	public static String getAppKey() {
		return fPayConfig.appKey;
	}

	public static String getAppSecret() {
		return fPayConfig.appSecret;
	}

	public static String getChannelType() {
		return fPayConfig.channelType;
	}

	public static String getVersion() {
		return fPayConfig.version;
	}

	public static String getMerNo() {
		return fPayConfig.merNo;
	}

	public static String getNotifyUrl() {
		return fPayConfig.notifyUrl;
	}

	public static String getGetAuthorizationUrl() {
		return fPayConfig.getAuthorizationUrl;
	}

	public static String getPlaceAnOrderUrl() {
		return fPayConfig.placeAnOrderUrl;
	}

	public static String getRefundUrl() {
		return fPayConfig.refundUrl;
	}

	public static String getQueryUrl() {
		return fPayConfig.queryUrl;
	}

	public static String getBillDownloadUrl() {
		return fPayConfig.billDownloadUrl;
	}

	public static String getPayAmount() {
		return fPayConfig.payAmount;
	}
}
